package com.yogurt.starter;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(MyStarterProperties.class)
public class MyStarterAutoConfiguration {

    private final MyStarterProperties myStarterProperties;

    public MyStarterAutoConfiguration(MyStarterProperties myStarterProperties) {
        this.myStarterProperties = myStarterProperties;
    }

    @Bean
    public MyService myService() {
        return new MyService(myStarterProperties.getName(), myStarterProperties.getAge());
    }
}
